#include <iostream>
#include <vector>
using namespace std;

bool check(int m, int n, int x, int y, vector<vector<char>>& room)
{
    return x >= 0 && x < m && y >= 0 && y < n && room[x][y] == '.';
}

int main()
{
    int m, n;
    while (cin >> m >> n)
    {
        int start_m, start_n;
        vector<vector<char>> room(m, vector<char>(n));
        for (int i = 0; i < m; ++i)
        {
            string str;
            cin >> str;
            for (int j = 0; j < n; ++j)
            {
                room[i][j] = str[j];
                if (room[i][j] == '@')
                {
                    start_m = i;
                    start_n = j;
                }
            }
        }

        //vector<pair<int, int>> cur = {make_pair(start_m, start_n)};
        vector<pair<int, int>> cur;
        cur.emplace_back(start_m, start_n);
        room[start_m][start_n] = ' ';
        int count = 1;
        while (!cur.empty())
        {
            vector<pair<int, int>> next;
            for (auto& it : cur)
            {
                int x = it.first;
                int y = it.second;
                if (check(m, n, x - 1, y, room))
                {
                    ++count;
                    room[x - 1][y] = ' ';
                    next.emplace_back(x - 1, y);
                }
                if (check(m, n, x + 1, y, room))
                {
                    ++count;
                    room[x + 1][y] = ' ';
                    next.emplace_back(x + 1, y);
                }
                if (check(m, n, x, y - 1, room))
                {
                    ++count;
                    room[x][y - 1] = ' ';
                    next.emplace_back(x, y - 1);
                }
                if (check(m, n, x, y + 1, room))
                {
                    ++count;
                    room[x][y + 1] = ' ';
                    next.emplace_back(x, y + 1);
                }
            }
            cur = next;
        }
        cout << count << endl;
    }
    return 0;
}